﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyVoiceControl.Data;
using System.Xml.Serialization;
using System.IO;


namespace MyVoiceControl.Engine
{
    public class ProfileManager
    {
        public ProfileManager()
        {
            _profiles = new List<ControlProfile>();
        }
        private List<ControlProfile> _profiles;
        public List<ControlProfile> Profiles
        {
            get
            {
                return _profiles;
            }
            set
            {
                _profiles = value;
            }
        }
        public void LoadProfile(string profilePath)
        {
            ControlProfile newProfile = new ControlProfile();
            StreamReader sr = new StreamReader(profilePath);
            XmlSerializer dser = new XmlSerializer(typeof(ControlProfile));
            _profiles.Add((ControlProfile)dser.Deserialize(sr));
            sr.Close();
        }
        public void SaveProfile(string profilePath, ControlProfile profile)
        {
            TextWriter writer = new StreamWriter(profilePath);
            XmlSerializer ser = new XmlSerializer(typeof(ControlProfile));
            ser.Serialize(writer, profile);
            writer.Close();
        }
    }
}
